<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>全部人员管理 - 基本信息修改</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <style>
        .discell {
            text-align: right;
            width: 20%;
        }

        .input {
            width: 30%;
        }
        .data-loading{
            position: absolute;
            width: 100%;
            line-height: 100px;
            display: none;
            text-align: center;
        }
    </style>
</head>
<body>
<div class="mini-fit" style="margin-bottom: 40px;">
    <form id="form1" method="post" style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
        <!-- 用户 编辑框START-->
        <div id="editform" class="form" style="padding:10px;">
            <input name="id" id="id" class="mini-hidden" style="width: 100%;" readonly/>
            <input name="pmid" id="pmid" class="mini-hidden" style="width: 100%;" readonly/>
            <input name="orgName" class="mini-hidden" style="width: 100%;" readonly/>
            <input name="priNum" id="priNum" class="mini-hidden" style="width: 100%" readonly/>
            <table class="form-table" align="center" style="width:85%" cellspacing="8">
                <tr>
                    <td style="font-weight: bold;text-align: center">基础信息:</td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>姓&emsp;&emsp;名:</td>
                    <td class="input">
                        <input name="pName" id="pName" class="mini-textbox" required="true" style="width: 80%;" readonly/>
                    </td>
                    <td class="discell">曾&nbsp;&nbsp;用&nbsp;&nbsp;名:</td>
                    <td class="input">
                        <input name="usedName" id="usedName" class="mini-textbox" value="无" style="width: 80%;"/>
                    </td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>性&emsp;&emsp;别:</td>
                    <td class="input">
                        <input name="sex" id="sex" class="mini-combobox" required="true"
                               textField="codeName" valueField="codeId" emptyText="请选择..." style="width: 80%;"
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=2_2&pcodeId=-1&sn=1" readonly
                        />
                    </td>
                    <td class="discell"><font color="#dc143c">*</font>民&emsp;&emsp;族:</td>
                    <td>
                        <input name="nationality" id="nationality" class="mini-combobox" required="true"
                               textField="codeName" valueField="codeId" emptyText="请选择..." style="width: 80%;"
                               url="/azbj/shzzgl/socialOrgInfo/getComboboxData?codeType=2_4" readonly
                        />
                    </td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>证件类型:</td>
                    <td>
                        <input name="idType" id="idType" class="mini-combobox" required="true" onvaluechanged="onIdTypeMouseOut()"
                               textField="codeName" valueField="codeId" emptyText="请选择..." style="width: 80%;"
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=2_13&pcodeId=-1&sn=1" readonly
                        />
                    </td>
                    <td class="discell">证件号码:</td>
                    <td>
                        <input name="idNum" id="idNum" class="mini-textbox"
                               onvaluechanged="onMouseOut()" style="width: 80%;" readonly/>
                    </td>
                </tr>
                <tr>
                    <td class="discell">出生日期:</td>
                    <td class="input">
                        <input property="editor" class="mini-datepicker" id="age" name="age" allowInput="false" style="width: 80%;" readonly/>
                    </td>
                    <td class="discell">入监日期:</td>
                    <td class="input">
                        <input property="editor" class="mini-datepicker" id="addtime" name="addtime" allowInput="false" style="width: 80%;" readonly/>
                    </td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>文化程度:</td>
                    <td >
                        <input name="education" id="education" class="mini-combobox"
                               textField="codeName" valueField="codeId" emptyText="请选择..." style="width: 80%;"
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=2_5&pcodeId=0&sn=0" required="true" readonly
                        />
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <hr/>
                    </td>
                </tr>
                <tr>
                    <td style="font-weight: bold;text-align: center">户籍信息:</td>
                </tr>
                <tr>
                    <td class="discell"></td>
                    <td class="input" >
                        <input name="hjType" id="hjType" class="mini-radiobuttonlist"
                               data="[{ id: ''+'01', name: '户籍完整人员' },{ id: ''+'02', name: '查不清户籍人员' }]"
                               textField="name" valueField="id" value="01"
                               readonly/>
                    </td>
                </tr>
                <tr id="hjlx">
                    <td class="discell"><font color="#dc143c">*</font>户籍类型:</td>
                    <td colspan="3">
                        <input name="priAddr" id="priAddr" class="mini-radiobuttonlist"
                               data="[{ id: ''+'01', name: '农村户籍' },{ id: ''+'02', name: '城镇户籍' },{ id: ''+'04', name: '非大陆籍' }]"
                               textField="name" valueField="id" value="01"
                                readonly/>
                    </td>
                </tr>


            </table>
        </div>

        <!-- 户籍信息-->
        <div id="wzhjry" class="form" style="padding:10px;">
            <table class="form-table" align="center" style="width:85%" cellspacing="8">
                <tr>
                    <td style="width: 20%;text-align: right"><font color="#dc143c">*</font>
                        户籍地址:
                    </td>
                    <td colspan="3" style="width: 80%">
                        <input id="nativepro" name="nativepro" class="mini-combobox" readonly emptyText="省份"
                               style="width:22%;" required="true"
                               textfield="codeName" valueField="codeId"
                               onclick="onDeptChanged('nativepro')" onvaluechanged="onValueChanged('nativepro')"/>
                        <input id="nativecity" name="nativecity" class="mini-combobox" readonly emptyText="市"
                               style="width: 23%" required="true"
                               textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecity')"
                               onvaluechanged="onValueChanged('nativecity')"/>
                        <input id="nativecou" name="nativecou" class="mini-combobox" readonly emptyText="县"
                               style="width: 23%" required="true"
                               textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecou')"
                               onvaluechanged="onValueChanged('nativecou')"/>
                        <input id="nativevill" name="nativevill" class="mini-combobox"  emptyText="街道" style="width:23%"
                               textfield="codeName" valueField="codeId"onclick="onDeptChanged('nativevill')" readonly
                               required="true" showNullItem="true" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 20%;text-align: right"></td>
                    <td colspan="3" style="width: 80%">
                        <input class="mini-textbox" readonly style="width: 92.5%" emptyText="详细地址" id="nativenum"
                               name="nativenum" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td style="width: 20%;text-align: right">
                        <#if "${localCode !''}"=='140000'>
                            日常居住地:
                        <#else>
                            居住地址:
                        </#if>
                    </td>
                    <td colspan="3" style="width: 80%">
                        <input id="placepro" name="placepro" class="mini-combobox" emptyText="省份" style="width:22%;"
                               textfield="codeName" valueField="codeId"
                               onclick="onLiveChanged('placepro')" onvaluechanged="onChanged('placepro')"/>
                        <input id="placecity" name="placecity" class="mini-combobox" emptyText="市" style="width: 23%"
                               textfield="codeName" valueField="codeId" onclick="onLiveChanged('placecity')"
                               onvaluechanged="onChanged('placecity')"/>
                        <input id="placecou" name="placecou" class="mini-combobox" emptyText="县" style="width: 23%"
                               textfield="codeName" valueField="codeId" onclick="onLiveChanged('placecou')"
                               onvaluechanged="onChanged('placecou')"/>
                        <input id="placevill" name="placevill" class="mini-combobox" emptyText="街道" style="width: 23%" showNullItem="true"
                               textfield="codeName" valueField="codeId" onclick="onLiveChanged('placevill')"/>

                    </td>
                </tr>
                <tr>
                    <td style="width: 20%;text-align: right"></td>
                    <td colspan="3" style="width: 80%">
                        <input class="mini-textbox" style="width: 92.5%" emptyText="详细地址" id="placenum" name="placenum"/>
                    </td>
                </tr>
            </table>
        </div>


        <#--查不清户籍人员-->
        <div id="cbqhj" class="form" style="padding:10px;display: none">
            <table class="form-table" align="center" style="margin-left: 10%;margin-right: 10%" cellspacing="8">

                <tr>
                    <td style="width: 20%;text-align: right"><font color="#dc143c">*</font>
                        户籍地址:
                    </td>
                    <td colspan="3" style="width: 80%">
                        户籍地址不明
                    </td>

                </tr>
                <tr>
                    <td style="width: 20%;text-align: right">
                        <font color="#dc143c">*</font>原侦查机关所在地:
                    </td>
                    <td colspan="3"  style="width: 80%">
                        <input id="investigatePro" name="investigatePro" class="mini-combobox" emptyText="省份" style="width:22%;"
                               textfield="codeName" valueField="codeId" required="true"
                               onclick="onNoLiveChanged('investigatePro')" onvaluechanged="onNoChanged('investigatePro')" readonly/>
                        <input id="investigateCity" name="investigateCity" class="mini-combobox" emptyText="市" style="width: 23%"
                               textfield="codeName" valueField="codeId" onclick="onNoLiveChanged('investigateCity')"
                               required="true"
                               onvaluechanged="onNoChanged('investigateCity')" readonly/>
                        <input id="investigateCou" name="investigateCou" class="mini-combobox" emptyText="县" style="width: 23%"
                               textfield="codeName" valueField="codeId" onclick="onNoLiveChanged('investigateCou')"
                               required="true"
                               onvaluechanged="onNoChanged('investigateCou')" readonly/>
                        <input id="investigateVill" name="investigateVill" class="mini-combobox" emptyText="街道" style="width: 23%"
                               required="true"
                               textfield="codeName" valueField="codeId"onclick="onNoLiveChanged('investigateVill')" readonly/>

                    </td>
                </tr>
                <tr>
                    <td style="width: 20%;text-align: right"></td>
                    <td colspan="3" style="width: 80%">
                        <input class="mini-textbox" style="width: 92.5%" emptyText="详细地址" id="investigateNum" name="investigateNum"
                               required="true" readonly/>
                    </td>
                </tr>
            </table>
        </div>

        <div id="fdlj" class="form" style="padding:10px;display: none">
            <table class="form-table" align="center" style="margin-left: 10%;margin-right: 10%" cellspacing="8">
                <tr>
                    <td style="width: 20%;text-align: right">
                        <font color="#dc143c">*</font>具体类型:
                    </td>
                    <td colspan="3" style="width: 80%;">
                        <input name="detailType" id="detailType" class="mini-combobox"  value="${detailType!''}"
                               data="[{ id: 1, name: '外国籍' },{ id: 2, name: '无国籍' },{ id: 3, name: '香港' },{ id: 4, name: '澳门' },{ id: 5, name: '台湾' }]"
                               textField="name" valueField="id" value="1" required="true" showNullItem="false" /><#--onvaluechanged="jsOnclick()"-->
                    </td>
                </tr>
                <tr>
                    <td style="width: 20%;text-align: right">
                        <font color="#dc143c">*</font>逮捕机构:
                    </td>
                    <td colspan="3" style="width: 80%">
                        <input id="arrestpro" name="arrestpro" class="mini-combobox" required="true" emptyText="省份"
                               style="width:22%;"
                               textfield="codeName" valueField="codeId"
                               onclick="onDBLiveChanged('arrestpro')" onvaluechanged="onDBChanged('arrestpro')"/>
                        <input id="arrestcity" name="arrestcity" class="mini-combobox" required="true" emptyText="市"
                               style="width: 23%"
                               textfield="codeName" valueField="codeId" onclick="onDBLiveChanged('arrestcity')"
                               onvaluechanged="onDBChanged('arrestcity')"/>
                        <input id="arrestcou" name="arrestcou" class="mini-combobox" required="true" emptyText="县"
                               style="width: 23%"
                               textfield="codeName" valueField="codeId" onclick="onDBLiveChanged('arrestcou')"
                               onvaluechanged="onDBChanged('arrestcou')"/>
                        <input id="arrestvill" name="arrestvill" class="mini-combobox" emptyText="街道" style="width: 23%"
                               textfield="codeName" valueField="codeId"onclick="onDBLiveChanged('arrestvill')" required="true"/>

                    </td>
                </tr>
                <tr>
                    <td style="width: 20%;text-align: right"></td>
                    <td colspan="3" style="width: 80%">
                        <input class="mini-textbox" required="true" style="width: 92.5%" emptyText="详细地址" name="arrestnum"
                               id="arrestnum"/>
                    </td>
                </tr>
            </table>

        </div>

    </form>
</div>
<div style="position: absolute;bottom: 0;line-height:40px;width: 100%;border-top:1px solid #dfdfdf;text-align: center">
    <a class="mini-button" iconCls="fa-save" plain="true" style="font-size: 15px " onclick="saveData()">保存</a>
</div>


<script type="text/javascript">
    mini.parse();
    var form = new mini.Form("form1");
    var name = mini.get("pName").getValue();
    var id = mini.get("id");
    var priNum = mini.get("priNum");
    var idNum = mini.get("idNum");
    var idType = mini.get("idType");
    var nativepro = mini.get("nativepro");
    var nativecity = mini.get("nativecity");
    var nativecou = mini.get("nativecou");
    var nativevill = mini.get("nativevill");
    var nativenum = mini.get("nativenum");

    var placepro = mini.get("placepro");
    var placecity = mini.get("placecity");
    var placecou = mini.get("placecou");
    var placevill = mini.get("placevill");
    var placenum = mini.get("placenum");

    var arrestpro = mini.get("arrestpro");
    var arrestcity = mini.get("arrestcity");
    var arrestcou = mini.get("arrestcou");
    var arrestvill = mini.get("arrestvill");
    var arrestnum = mini.get("arrestnum");

    var investigatePro = mini.get("investigatePro");
    var investigateCity = mini.get("investigateCity");
    var investigateCou = mini.get("investigateCou");
    var investigateVill = mini.get("investigateVill");
    var investigateNum = mini.get("investigateNum");

    var age = mini.get("age");
    var addtime = mini.get("addtime");

    function saveData() {
        //校验系统中是否存在该身份证的预安置人员
        var mark = true;
        if(!mark) {
            mini.confirm("系统中已经存在该身份证号的预安置人员,确定继续添加？",
                "确定添加？",
                function (action) {
                    if (action == "ok") {
                        if (idNum.getValue() != "") {  // 如果身份证号不为空，对身份号进行校验
                            if(idType.getValue()=="1" || idType.getValue()=="2") { //当证件类型为身份证号或者临时身份证号时才进行校验
                                if(idNum.getValue()=="无"){

                                } else if (!onIDCardsValidation(idNum.getValue())) {
                                    mini.alert("请输入正确的身份证号");
                                    return;
                                }
                            }
                        }

                        //校验出生日期和入监日期，出生日期不能在入监日期之后
                        if(age.getValue()!="" && addtime.getValue()!=""){
                            if(age.getValue() > addtime.getValue()){
                                mini.alert("入监日期应该大于出生日期");
                                return;
                            }
                        }

                        form.validate();
                        if (form.isValid() == false) {
                            return;
                        }
                        var data = form.getData();
                        var json = mini.encode(data);

                        mini.mask({
                            el: document.body,
                            cls: 'mini-mask-loading',
                            html: '加载中...'
                        });
                        $.ajax({
                            url: "/azbj/inmates/baseinfo/save",
                            data: {data: json},
                            type: "post",
                            success: function (success) {
                                mini.unmask(document.body);
                                if (success.code == 1) {
                                    var idstr = success.data.id;
                                    var priNumstr = success.data.priNum;
                                    priNum.setValue(priNumstr);
                                    id.setValue(idstr);
                                    mini.alert("保存成功");
                                }else if(success.code=5599){
                                    mini.alert(success.message);
                                }else {
                                    mini.alert("保存失败");
                                }
                            }, error: function () {
                                mini.unmask(document.body);
                                mini.alert("系统异常");
                            }

                        })
                    }
                });
        } else {
            if (idNum.getValue() != "") {  // 如果身份证号不为空，对身份号进行校验
                if(idType.getValue()=="1" || idType.getValue()=="2") { //当证件类型为身份证号或者临时身份证号时才进行校验
                    if(idNum.getValue()=="无"){

                    } else if(!onIDCardsValidation(idNum.getValue())) {
                        mini.alert("请输入正确的身份证号");
                        return;
                    }
                }
            }

            //校验出生日期和入监日期，出生日期不能在入监日期之后
            if(age.getValue()!="" && addtime.getValue()!=""){
                if(age.getValue() > addtime.getValue()){
                    mini.alert("入监日期应该大于出生日期");
                    return;
                }
            }

            form.validate();
            if (form.isValid() == false) {
                return;
            }
            var data = form.getData();
            var json = mini.encode(data);

            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '加载中...'
            });
            $.ajax({
                url: "/azbj/inmates/baseinfo/save",
                data: {data: json},
                type: "post",
                success: function (success) {
                    mini.unmask(document.body);
                    if (success.code == 1) {
                        var idstr = success.data.id;
                        var priNumstr = success.data.priNum;
                        priNum.setValue(priNumstr);
                        id.setValue(idstr);
                        mini.alert("保存成功");
                    }else if(success.code=5599){
                        mini.alert(success.message);
                    }else {
                        mini.alert("保存失败");
                    }
                }, error: function () {
                    mini.unmask(document.body);
                    mini.alert("系统异常");
                }

            })
        }
    }

    function hjOnclick() {
        var value = mini.get("priAddr").getValue();
        if (value == "02") { // 城镇户籍
            document.getElementById("wzhjry").style.display = "block";
            document.getElementById("fdlj").style.display = "none";
            document.getElementById("cbqhj").style.display = "none";

            nativepro.setValue("");
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
            nativenum.setValue("");

            placepro.setValue("");
            placecity.setValue("");
            placecou.setValue("");
            placevill.setValue("");
            placenum.setValue("");

            arrestpro.setValue("");
            arrestcity.setValue("");
            arrestcou.setValue("");
            arrestvill.setValue("");
            arrestnum.setValue("");

            investigatePro.setValue("");
            investigateCity.setValue("");
            investigateCou.setValue("");
            investigateVill.setValue("");
            investigateNum.setValue("");

        }else if (value == "03") {
            // 户籍为监所
            document.getElementById("wzhjry").style.display = "none";
            document.getElementById("fdlj").style.display = "none";
            document.getElementById("cbqhj").style.display = "none";
            nativepro.setValue("");
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
            nativenum.setValue("");

            placepro.setValue("");
            placecity.setValue("");
            placecou.setValue("");
            placevill.setValue("");
            placenum.setValue("");

            arrestpro.setValue("");
            arrestcity.setValue("");
            arrestcou.setValue("");
            arrestvill.setValue("");
            arrestnum.setValue("");

            investigatePro.setValue("");
            investigateCity.setValue("");
            investigateCou.setValue("");
            investigateVill.setValue("");
            investigateNum.setValue("");

        } else if (value == "04") {
            document.getElementById("wzhjry").style.display = "none";
            document.getElementById("fdlj").style.display = "block";
            document.getElementById("cbqhj").style.display = "none";
            nativepro.setValue("");
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
            nativenum.setValue("");

            placepro.setValue("");
            placecity.setValue("");
            placecou.setValue("");
            placevill.setValue("");
            placenum.setValue("");

            investigatePro.setValue("");
            investigateCity.setValue("");
            investigateCou.setValue("");
            investigateVill.setValue("");
            investigateNum.setValue("");

        } else {//农村户籍
            document.getElementById("wzhjry").style.display = "block";
            document.getElementById("fdlj").style.display = "none";
            document.getElementById("cbqhj").style.display = "none";

            arrestpro.setValue("");
            arrestcity.setValue("");
            arrestcou.setValue("");
            arrestvill.setValue("");
            arrestnum.setValue("");

            investigatePro.setValue("");
            investigateCity.setValue("");
            investigateCou.setValue("");
            investigateVill.setValue("");
            investigateNum.setValue("");
        }
    }

    /**
     * 查不清户籍 与 户籍完整人员大类显示控制方法
     */
    function hjTypeOnclick() {
        var value = mini.get("hjType").getValue();
        var priAddrValue = mini.get("priAddr").getValue();
        if (value == "02") { //查不清户籍人员
            document.getElementById("wzhjry").style.display = "none";
            document.getElementById("fdlj").style.display = "none";
            document.getElementById("hjlx").style.display = "none";
            document.getElementById("cbqhj").style.display = "block";
            nativepro.setValue("");
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
            nativenum.setValue("");

            placepro.setValue("");
            placecity.setValue("");
            placecou.setValue("");
            placevill.setValue("");
            placenum.setValue("");

            arrestpro.setValue("");
            arrestcity.setValue("");
            arrestcou.setValue("");
            arrestvill.setValue("");
            arrestnum.setValue("");

        }else{
            if(priAddrValue=="04"){//非大陆籍
                document.getElementById("wzhjry").style.display = "none";
                document.getElementById("hjlx").style.display = "";
                document.getElementById("fdlj").style.display = "block";
                document.getElementById("cbqhj").style.display = "none";


                arrestpro.setValue("");
                arrestcity.setValue("");
                arrestcou.setValue("");
                arrestvill.setValue("");
                arrestnum.setValue("");

                prisonspro.setValue("");
                prisonscity.setValue("");
                prisonscou.setValue("");
                prisonsvill.setValue("");
                prisonsnum.setValue("");

                investigatePro.setValue("");
                investigateCity.setValue("");
                investigateCou.setValue("");
                investigateVill.setValue("");
                investigateNum.setValue("");
            }else{
                document.getElementById("wzhjry").style.display = "block";
                document.getElementById("hjlx").style.display = "";
                document.getElementById("fdlj").style.display = "none";
                document.getElementById("cbqhj").style.display = "none";

                arrestpro.setValue("");
                arrestcity.setValue("");
                arrestcou.setValue("");
                arrestvill.setValue("");
                arrestnum.setValue("");

                prisonspro.setValue("");
                prisonscity.setValue("");
                prisonscou.setValue("");
                prisonsvill.setValue("");
                prisonsnum.setValue("");

                investigatePro.setValue("");
                investigateCity.setValue("");
                investigateCou.setValue("");
                investigateVill.setValue("");
                investigateNum.setValue("");
            }
        }
    }

    /**
     * 户籍地址
     * @param e
     */
        //**********************************************************************
        //点击
    var urltemp = "/azbj/getCodeDetail/?codeType=2_1&codeId=-2";
    //**********************************************************************

    function onDeptChanged(e) {
        // placepro placecity  placecou placevill
        if ("nativepro" == e) {
//**********************************************************************
            var value = nativepro.getValue();
//**********************************************************************
            nativepro.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=-1";
            nativepro.setUrl(url);
//**********************************************************************
            if(value!=''){
                nativepro.setValue(value);
            } else {
                nativepro.select(0);
            }
        }
//**********************************************************************
        if ("nativecity" == e) {
//**********************************************************************
            var value = nativecity.getValue();

            if(nativepro.getValue()==""){
                nativepro.setUrl(urltemp);
                nativepro.setValue("");
                nativecou.setUrl(urltemp);
                nativecou.setValue("");
                nativevill.setUrl(urltemp);
                nativevill.setValue("");
                return;
            }
//**********************************************************************
            var codeId = nativepro.getValue();
            nativecity.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            nativecity.setUrl(url);
//**********************************************************************
            if(value!=''){
                nativecity.setValue(value);
            } else {
                nativecity.select(0);
            }
        }
//**********************************************************************

        if ("nativecou" == e) {
//**********************************************************************
            var value = nativecou.getValue();

            if(nativecity.getValue()==""){
                nativecou.setUrl(urltemp);
                nativecou.setValue("");
                nativevill.setUrl(urltemp);
                nativevill.setValue("");
                return;
            }
//**********************************************************************
            var codeId = nativecity.getValue();
            nativecou.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            nativecou.setUrl(url);
//**********************************************************************
            if(value!=''){
                nativecou.setValue(value);
            } else {
                nativecou.select(0);
            }
//**********************************************************************
        }

        if ("nativevill" == e) {
//**********************************************************************
            var value = nativevill.getValue();

            if(nativecou.getValue()==""){
                nativevill.setUrl(urltemp);
                nativevill.setValue("");
                return;
            }
//**********************************************************************
            var parent_code = nativecou.getValue();
            nativevill.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            nativevill.setUrl(url);
//**********************************************************************
            if(value!=''){
                nativevill.setValue(value);
            } else {
                nativevill.select(0);
            }
//**********************************************************************
        }
    }

    function onValueChanged(e) {
        if ("nativepro" == e) {
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
        }

        if ("nativecity" == e) {
            nativecou.setValue("");
            nativevill.setValue("");
        }

        if ("nativecou" == e) {
            nativevill.setValue("");
        }

    }

    /**
     * 居住地址
     *     placepro  placecity placecou placevill placenum
     * @param e
     */
    function onLiveChanged(e) {
        if ("placepro" == e) {
            var value = placepro.getValue();
            placepro.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=-1";
            placepro.setUrl(url);
            if(value!=''){
                placepro.setValue(value);
            } else {
                placepro.select(0);
            }
        }
        if ("placecity" == e) {
            var value = placecity.getValue();

            if(placepro.getValue()==""){
                placepro.setUrl(urltemp);
                placepro.setValue("");
                placecou.setUrl(urltemp);
                placecou.setValue("");
                placevill.setUrl(urltemp);
                placevill.setValue("");
                return;
            }
            var codeId = placepro.getValue();
            placecity.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            placecity.setUrl(url);
            if(value!=''){
                placecity.setValue(value);
            } else {
                placecity.select(0);
            }
        }

        if ("placecou" == e) {
            var value = placecou.getValue();

            if(placecity.getValue()==""){
                placecou.setUrl(urltemp);
                placecou.setValue("");
                placevill.setUrl(urltemp);
                placevill.setValue("");
                return;
            }
            var codeId = placecity.getValue();
            placecou.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            placecou.setUrl(url);
            if(value!=''){
                placecou.setValue(value);
            } else {
                placecou.select(0);
            }
        }
        if ("placevill" == e) {
            var value = placevill.getValue();

            if(placecou.getValue()==""){
                placevill.setUrl(urltemp);
                placevill.setValue("");
                return;
            }
            var parent_code = placecou.getValue();
            placevill.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            placevill.setUrl(url);
            if(value!=''){
                placevill.setValue(value);
            } else {
                placevill.select(0);
            }
        }
    }

    function onChanged(e) {
        if ("placepro" == e) {
            placecity.setValue("");
            placecou.setValue("");
            placevill.setValue("");
        }
        if ("placecity" == e) {
            placecou.setValue("");
            placevill.setValue("");

        }
        if ("placecou" == e) {
            placevill.setValue("");
        }

    }

    /**
     * 监所地址
     * @param e
     */
    function onJsDeptChanged(e) {
        if ("prisonspro" == e) {
            var value = prisonspro.getValue();
            prisonspro.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=-1";
            prisonspro.setUrl(url);
            if(value!=''){
                prisonspro.setValue(value);
            } else {
                prisonspro.select(0);
            }
        }
        if ("prisonscity" == e) {
            var value = prisonscity.getValue();

            if(prisonspro.getValue()==""){
                prisonspro.setUrl(urltemp);
                prisonspro.setValue("");
                prisonscou.setUrl(urltemp);
                prisonscou.setValue("");
                prisonsvill.setUrl(urltemp);
                prisonsvill.setValue("");
                return;
            }
            var codeId = prisonspro.getValue();
            prisonscity.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            prisonscity.setUrl(url);
            if(value!=''){
                prisonscity.setValue(value);
            } else {
                prisonscity.select(0);
            }
        }

        if ("prisonscou" == e) {
            var value = prisonscou.getValue();

            if(prisonscity.getValue()==""){
                prisonscou.setUrl(urltemp);
                prisonscou.setValue("");
                prisonsvill.setUrl(urltemp);
                prisonsvill.setValue("");
                return;
            }
            var codeId = prisonscity.getValue();
            prisonscou.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            prisonscou.setUrl(url);
            if(value!=''){
                prisonscou.setValue(value);
            } else {
                prisonscou.select(0);
            }
        }

        if ("prisonsvill" == e) {
            var value = prisonsvill.getValue();

            if(prisonscou.getValue()==""){
                prisonsvill.setUrl(urltemp);
                prisonsvill.setValue("");
                return;
            }
            var parent_code = prisonscou.getValue();
            prisonsvill.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            prisonsvill.setUrl(url);
            if(value!=''){
                prisonsvill.setValue(value);
            } else {
                prisonsvill.select(0);
            }
        }
    }

    function onJSValueChanged(e) {
        if ("prisonspro" == e) {
            prisonscity.setValue("");
            prisonscou.setValue("");
            prisonsvill.setValue("");
        }

        if ("prisonscity" == e) {
            prisonscou.setValue("");
            prisonsvill.setValue("");
        }

        if ("prisonscou" == e) {
            prisonsvill.setValue("");
        }

    }


    /**
     * 逮捕地址
     * arrestpro  arrestcity arrestcou arrestvill
     * @param e
     */
    function onDBLiveChanged(e) {
        if ("arrestpro" == e) {
            var value = arrestpro.getValue();
            arrestpro.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=-1";
            arrestpro.setUrl(url);
            if(value!=''){
                arrestpro.setValue(value);
            } else {
                arrestpro.select(0);
            }
        }
        if ("arrestcity" == e) {
            var value = arrestcity.getValue();

            if(arrestpro.getValue()==""){
                arrestpro.setUrl(urltemp);
                arrestpro.setValue("");
                arrestcou.setUrl(urltemp);
                arrestcou.setValue("");
                arrestvill.setUrl(urltemp);
                arrestvill.setValue("");
                return;
            }
            var codeId = arrestpro.getValue();
            arrestcity.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            arrestcity.setUrl(url);
            if(value!=''){
                arrestcity.setValue(value);
            } else {
                arrestcity.select(0);
            }
        }

        if ("arrestcou" == e) {
            var value = arrestcou.getValue();

            if(arrestcity.getValue()==""){
                arrestcou.setUrl(urltemp);
                arrestcou.setValue("");
                arrestvill.setUrl(urltemp);
                arrestvill.setValue("");
                return;
            }
            var codeId = arrestcity.getValue();
            arrestcou.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            arrestcou.setUrl(url);
            if(value!=''){
                arrestcou.setValue(value);
            } else {
                arrestcou.select(0);
            }
        }

        if ("arrestvill" == e) {
            var value = arrestvill.getValue();

            if(arrestcou.getValue()==""){
                arrestvill.setUrl(urltemp);
                arrestvill.setValue("");
                return;
            }
            var parent_code = arrestcou.getValue();
            arrestvill.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            arrestvill.setUrl(url);
            if(value!=''){
                arrestvill.setValue(value);
            } else {
                arrestvill.select(0);
            }
        }
    }

    function onDBChanged(e) {
        if ("arrestpro" == e) {
            arrestcity.setValue("");
            arrestcou.setValue("");
            arrestvill.setValue("");
        }
        if ("arrestcity" == e) {
            arrestcou.setValue("");
            arrestvill.setValue("");

        }
        if ("arrestcou" == e) {
            arrestvill.setValue("");
        }

    }


    window.onload = function () {
        var data = parent.setChildValue();
        mini.get("pName").setEnabled(false);
        mini.get("sex").setEnabled(false);
        mini.get("nationality").setEnabled(false);
        mini.get("idType").setEnabled(false);
        mini.get("idNum").setEnabled(false);
        mini.get("age").setEnabled(false);
        mini.get("addtime").setEnabled(false);
        mini.get("education").setEnabled(false);
        mini.get("hjType").setEnabled(false);
        mini.get("priAddr").setEnabled(false);
        mini.get("nativepro").setEnabled(false);
        mini.get("nativecity").setEnabled(false);
        mini.get("nativecou").setEnabled(false);
        mini.get("nativevill").setEnabled(false);
        mini.get("nativenum").setEnabled(false);
        mini.get("investigatePro").setEnabled(false);
        mini.get("investigateCity").setEnabled(false);
        mini.get("investigateCou").setEnabled(false);
        mini.get("investigateVill").setEnabled(false);
        mini.get("investigateNum").setEnabled(false);
        priNum.setValue(data.priNum);
        SetData(priNum.getValue());
    }

    function SetData(data) {
        if (data) {
            mini.get("id").setEnabled(false);
        }
        // 根据ID去数据库中查询数据
        $.ajax({
            url: "/azbj/inmates/getbaseinfo?prinum=" + data,
            type: "post",
            dataType: "json",
            success: function (bsdata) {
                var bf = mini.decode(bsdata);
                form.setData(bsdata);
                form.setChanged(false);
                nativepro.setData([{codeId: bsdata.nativepro, codeName: bsdata.nativeproName}]);
                nativecity.setData([{codeId: bsdata.nativecity, codeName: bsdata.nativecityName}]);
                nativecou.setData([{codeId: bsdata.nativecou, codeName: bsdata.nativecouName}]);
                nativevill.setData([{codeId: bsdata.nativevill, codeName: bsdata.nativevillName}]);

                placepro.setData([{codeId: bsdata.placepro, codeName: bsdata.placeproName}]);
                placecity.setData([{codeId: bsdata.placecity, codeName: bsdata.placecityName}]);
                placecou.setData([{codeId: bsdata.placecou, codeName: bsdata.placecouName}]);
                placevill.setData([{codeId: bsdata.placevill, codeName: bsdata.placevillName}]);

                arrestpro.setData([{codeId: bsdata.arrestpro, codeName: bsdata.arrestproName}]);
                arrestcity.setData([{codeId: bsdata.arrestcity, codeName: bsdata.arrestcityName}]);
                arrestcou.setData([{codeId: bsdata.arrestcou, codeName: bsdata.arrestcouName}]);
                arrestvill.setData([{codeId: bsdata.arrestvill, codeName: bsdata.arrestvillName}]);

                investigatePro.setData([{codeId: bsdata.investigatePro, codeName: bsdata.investigateProName}]);
                investigateCity.setData([{codeId: bsdata.investigateCity, codeName: bsdata.investigateCityName}]);
                investigateCou.setData([{codeId: bsdata.investigateCou, codeName: bsdata.investigateCouName}]);
                investigateVill.setData([{codeId: bsdata.investigateVill, codeName: bsdata.investigateVillName}]);
                if(bsdata.hjType=='02'){
                    hjTypeOnclick();
                }else{
                    // hjOnclick();
                    var value = bsdata.priAddr;
                    if (value == "02") { // 城镇户籍
                        document.getElementById("wzhjry").style.display = "block";
                        document.getElementById("fdlj").style.display = "none";
                        document.getElementById("cbqhj").style.display = "none";
                    } else if (value == "03") {
                        // 户籍为监所
                        document.getElementById("wzhjry").style.display = "none";
                        document.getElementById("fdlj").style.display = "none";
                        document.getElementById("cbqhj").style.display = "none";
                    } else if (value == "04") {
                        document.getElementById("wzhjry").style.display = "none";
                        document.getElementById("fdlj").style.display = "block";
                        document.getElementById("cbqhj").style.display = "none";
                    } else {//农村户籍
                        document.getElementById("wzhjry").style.display = "block";
                        document.getElementById("fdlj").style.display = "none";
                        document.getElementById("cbqhj").style.display = "none";
                    }
                }
                //代表这条数据是双列管，审核中状态不可编译
                if(undefined != bsdata.slgspStatef && ""!= bsdata.slgspStatef && bsdata.slgspStatef == "2"){
                    mini.alert("这条数据正在申请双列管，居住地址不可修改");
                    mini.get("placepro").setEnabled(false);
                    mini.get("placecity").setEnabled(false);
                    mini.get("placecou").setEnabled(false);
                    mini.get("placevill").setEnabled(false);
                    mini.get("placenum").setEnabled(false);
                }
            }
        });
    }

    /**
     * 查不清户籍人员地址
     */
    function onNoLiveChanged(e) {
        if ("investigateVill" == e) {
            var value = investigateVill.getValue();

            if(investigateCou.getValue()==""){
                investigateVill.setUrl(urltemp);
                investigateVill.setValue("");
                return;
            }
            var parent_code = investigateCou.getValue();
            investigateVill.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            investigateVill.setUrl(url);
            if(value!=''){
                investigateVill.setValue(value);
            } else {
                investigateVill.select(0);
            }
        }
    }

    function onNoChanged(e) {
        if ("investigatePro" == e) {
            investigateCity.setValue("");
            investigateCou.setValue("");
            investigateVill.setValue("");
        }
        if ("investigateCity" == e) {
            investigateCou.setValue("");
            investigateVill.setValue("");

        }
        if ("investigateCou" == e) {
            investigateVill.setValue("");
        }

    }

    function onMouseOut() {
        var id = mini.get("idNum").getValue();
        if (idNum.getValue() != "") {
            if(idType.getValue()=="1" || idType.getValue()=="2") { //当证件类型为身份证号或者临时身份证号时才进行校验
                if (id.length == 18 && onIDCardsValidation(idNum.getValue())) {
                    var age = id.substring(6, 10) + "-" + id.substring(10, 12) + "-" + id.substring(12, 14);
                    mini.get("age").setValue(age);
                    var num = id[16];
                    if(num%2 ==0){
                        mini.get("Sex").setValue("2");
                    } else {
                        mini.get("Sex").setValue("1");
                    }
                } else if (id.length == 15 && onIDCardsValidation(idNum.getValue())) {
                    var num = id[14];
                    if(num%2 ==0){
                        mini.get("Sex").setValue("2");
                    } else {
                        mini.get("Sex").setValue("1");
                    }
                } else if(idNum.getValue()=="无"){

                }else {
                    mini.alert("请输入正确的身份证号码");
                }
            }
        }
    }

    function onIdTypeMouseOut() {
        var id = mini.get("idNum").getValue();
        if(idType.getValue()=="1" || idType.getValue()=="2") { //当证件类型为身份证号或者临时身份证号时才进行校验
            if (idNum.getValue() != "") {
                if (id.length == 18 && onIDCardsValidation(idNum.getValue())) {
                    var age = id.substring(6, 10) + "-" + id.substring(10, 12) + "-" + id.substring(12, 14);
                    mini.get("age").setValue(age);
                    var num = id[16];
                    if(num%2 ==0){
                        mini.get("Sex").setValue("2");
                    } else {
                        mini.get("Sex").setValue("1");
                    }
                } else if (id.length == 15 && onIDCardsValidation(idNum.getValue())) {
                    var num = id[14];
                    if(num%2 ==0){
                        mini.get("Sex").setValue("2");
                    } else {
                        mini.get("Sex").setValue("1");
                    }
                }else {
                    mini.alert("请输入正确的身份证号码");
                }
            }
        }
    }
</script>
</body>
</html>